﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>填充下拉框</title>
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Comm/Gener.js" type="text/javascript"></script>
    <script src="DDLBar.js" type="text/javascript"></script>
    <script src="../../CCFlowEnum.js" type="text/javascript"></script>
    <script src="../../Admin.js"></script>
    <script type="text/javascript">

        var extType = "";

        $(function () {

            extType = GetQueryString("ExtType");
            extType = extType == null || extType == undefined ? "" : extType;

            InitBar("DDLs");
            var html = "";
            //查询出来数据.
            //更新节点表单类型.
            var frmID = GetQueryString("FK_MapData");
            var refPK = GetQueryString("RefPK");
            var keyOfEn = GetQueryString("KeyOfEn");
            var thisPK = refPK + "_FullData";

            var en = new Entity("BP.Sys.MapExt");
            en.MyPK = thisPK;
            en.SetPKVal(en.MyPK);
            var n = en.RetrieveFromDBSources();

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_FoolFormDesigner_MapExt");
            handler.AddPara("FK_MapData", frmID);
            handler.AddPara("KeyOfEn", keyOfEn);
            handler.AddPara("MyPK", thisPK);
            var data = handler.DoMethodReturnString("TBFullCtrlDDL_Init");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            data = JSON.parse(data);
            mapdtls = data;

            if (data.length == 0) {

                $("#doc").html("<h3>没有要填充的下拉框字段.</h3>");
                return;
            }
            var tag6 = en.Tag6 || "0";
            $("#RB_Type_" + tag6).attr("checked", true);
            if (tag6 == "0") {
                $("#doc").show();
                $("#TB_Tag").hide();
            } else {
                $("#doc").hide();
                $("#TB_Tag").show();
                $("#TB_Tag").val(en.Tag);
            }
            var html = "<table style='width:99%;'>";
            for (var i = 0; i < data.length; i++) {
                var mapAttr = data[i];
                if (data[i].KeyOfEn == keyOfEn)
                    continue;
                html += "<tr>";
                html += "<th>下拉框:" + mapAttr.KeyOfEn + " - " + mapAttr.Name;
                html += "</tr>";

                html += "<tr>";
                html += "<td>";
                html += '<textarea rows=4 name=TB_' + mapAttr.KeyOfEn + '  name=TB_' + mapAttr.KeyOfEn + ' style="width:98%;" > ' + mapAttr.DefVal + '</textarea>';
                html += "</td>";
                html += "</tr>";

            }

            $("#doc").html(html);
            return;
        });
        function Save() {

            var str = "";
            var frmID = GetQueryString("FK_MapData");
            var refPK = GetQueryString("RefPK");

            var thisPK = refPK + "_FullData";
            //            var mapExt = new Entity("BP.Sys.MapExt", thisPK);
            //            var mapAtrr = new Entity("BP.Sys.MapAttr", frmID);
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_FoolFormDesigner_MapExt");
            handler.AddPara("FK_MapData", GetQueryString("FK_MapData"));
            handler.AddPara("Tag", $("#TB_Tag").val());
            handler.AddPara("Tag6", $("input[name='RB_Type']:checked").val());
            handler.AddPara("MyPK", thisPK);
            handler.AddPara("AttrOfOper", GetQueryString("KeyOfEn"));
            handler.AddFormData();
            var data = handler.DoMethodReturnString("TBFullCtrlDDL_Save");
            if (data.indexOf('err@') != -1) {
                alert(data);
                return;
            }

            Reload();
        }
        function ChangeShow(type) {
            if (type == 0) {
                $("#doc").show();
                $("#TB_Tag").hide();
            } else {
                $("#doc").hide();
                $("#TB_Tag").show();
            }

        }

    </script>
</head>
<body>
    <form id="cc">

        <div id="bar"></div>
        <div>
            下拉框填充方式：
            <input type="radio" name="RB_Type" id="RB_Type_0" value="0" onchange="ChangeShow(0)" />分别填充
            <input type="radio" name="RB_Type" id="RB_Type_1" value="1" onchange="ChangeShow(1)" />请求URL一次性获取数据填充
        </div>
        <div id="doc"></div>
        <textarea rows="4" name="TB_Tag" id="TB_Tag" style="width: 98%;"> </textarea>
        <fieldset>
            <legend>帮助.</legend>
            <ul>
                <li>填充下拉框的SQL, </li>
                <li>返回一个数据源用来填充下拉框，该行里必须有No,Name两个字段 No就是下拉框的值，Name就是下拉框的标签.</li>
                <li>
                    实例(选择的人员的岗位下拉框)：
                    <font color="green">
                        SELECT B.FK_Station AS No, A.Name FROM Port_Station A, Port_DeptEmpStation B
                        WHERE B.FK_Emp='@Key' AND B.Station=A.No
                    </font>
                </li>
                <li>@Key 系统约定的选择的编号.</li>
            </ul>
        </fieldset>
    </form>
</body>
</html>
